package com.cz.nongyetongv5.activity;

import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.graphics.drawable.BitmapDrawable;
import android.os.AsyncTask;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.Button;
import android.widget.PopupWindow;

import com.baidu.mapapi.map.BaiduMap;
import com.baidu.mapapi.map.MapStatus;
import com.baidu.mapapi.map.MapStatusUpdate;
import com.baidu.mapapi.map.MapStatusUpdateFactory;
import com.baidu.mapapi.map.MapView;
import com.baidu.mapapi.map.OverlayOptions;
import com.baidu.mapapi.map.PolygonOptions;
import com.baidu.mapapi.map.Stroke;
import com.baidu.mapapi.model.LatLng;
import com.baidu.mapapi.model.inner.GeoPoint;
import com.cz.nongyetongv5.R;
import com.cz.nongyetongv5.adapter.config.CommonConstants;
import com.cz.nongyetongv5.adapter.dao.DatabaseHelper;
import com.cz.nongyetongv5.application.InitApplication;
import com.cz.nongyetongv5.bean.BeiJianDanWei;
import com.cz.nongyetongv5.bean.User;
import com.cz.nongyetongv5.custom.BlueLoadingProgress;
import com.cz.nongyetongv5.custom.dialog.CustomDialog;
import com.cz.nongyetongv5.utils.ConfigUtil;
import com.cz.nongyetongv5.utils.GoHomeUtil;
import com.cz.nongyetongv5.utils.HttpUtils;
import com.cz.nongyetongv5.utils.HttpUtils.OnRequestExecuted;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;

public class JianGuanDuiXiangStatisticsActivity extends Activity implements
        OnClickListener {


    private WebView wvStart;

    private Button btnLeft;

    private Button btnRight;

    private Button btnLast;

    private User user;

    private ViewGroup btnBack;

    private BlueLoadingProgress blpLoading = null;

    private DatabaseHelper db = null;


    /**
     * 百度地图
     */
    //	BMapManager mBMapMan = null;
    MapView mvMap = null;
    private BaiduMap mBaiduMap;
    private MapStatus ms;

    /**
     * 地图覆盖物的数据（南京）
     */
    final String pukou_area = "31.984671,118.381594;31.975849,118.387029;118.373529,31.959392;118.37045,31.936459;118.383277,31.92996;118.391894,31.916664;118.409497,31.919607;118.425882,31.904032;118.434558,31.902514;118.444688,31.905087;118.454319,31.895251;118.47862,31.885638;118.472514,31.866539;118.481421,31.857309;118.49689,31.84939;118.511281,31.847436;118.531099,31.876491;118.570694,31.916337;118.591395,31.930968;118.623368,31.946554;118.651238,31.972001;118.709883,32.075472;118.782031,32.149359;118.782957,32.162666;118.774637,32.194454;118.754547,32.189896;118.7406,32.172988;118.736441,32.172507;118.737139,32.17993;118.742455,32.180435;118.746162,32.186735;118.742709,32.194862;118.745706,32.197228;118.740328,32.203742;118.737648,32.215992;118.730878,32.221523;118.726454,32.254908;118.682144,32.256105;118.675536,32.242756;118.653,32.216389;118.635816,32.207738;118.622744,32.210067;118.601533,32.202573;118.575801,32.207739;118.567162,32.203753;118.558481,32.204898;118.546244,32.199355;118.536764,32.201389;118.52958,32.195346;118.516517,32.200075;118.515014,32.189943;118.502245,32.182718;118.502273,32.170857;118.515613,32.143384;118.504634,32.144848;118.50541,32.139811;118.501179,32.136955;118.507166,32.127212;118.482753,32.123886;118.479286,32.121728;118.479214,32.115881;118.469439,32.107649;118.455509,32.104249;118.438027,32.092903;118.421833,32.09403;118.41833,32.087464;118.411198,32.085806;118.410358,32.081522;118.401416,32.082112;118.400728,32.070392;118.391688,32.066094;118.400939,32.054731;118.394621,32.047923;118.39259,32.038789;118.394766,32.032718;118.402415,32.028097;118.396248,32.017731;118.397612,31.99524;118.393793,31.988938;118.383355,31.987389;118.381594,31.984671";
    final String qixia_area = "119.083351,32.174839;119.08552,32.184844;119.125468,32.192353;119.141082,32.199694;119.166193,32.192159;119.190798,32.196084;119.201153,32.191093;119.221395,32.196304;119.227662,32.207134;119.245758,32.220087;119.247036,32.225619;119.165459,32.248275;119.148198,32.250854;119.104192,32.249187;119.088561,32.243426;119.069616,32.228654;119.040469,32.197355;119.018011,32.188116;118.963099,32.18344;118.879483,32.187918;118.873143,32.205506;118.859598,32.226164;118.846341,32.234056;118.830289,32.236759;118.814771,32.23672;118.803427,32.231924;118.77279,32.211294;118.782957,32.162666;118.782031,32.149359;118.77595,32.141041;118.785372,32.129541;118.804568,32.134572;118.812397,32.131316;118.809922,32.109301;118.824092,32.106086;118.823965,32.115063;118.841624,32.117376;118.844037,32.107848;118.850071,32.103222;118.899529,32.10889;118.913981,32.099989;118.899936,32.085238;118.892677,32.089115;118.881808,32.087443;118.893929,32.068108;118.883264,32.058953;118.88475,32.055842;118.890136,32.055494;118.891413,32.049285;118.903771,32.044847;118.903374,32.039139;118.922427,32.051765;118.926626,32.082926;118.938534,32.085386;118.957781,32.106097;118.967054,32.108357;118.976253,32.117266;118.981638,32.117613;118.98749,32.115868;118.988012,32.108892;118.986538,32.103117;118.978691,32.098123;118.975717,32.086202;118.977367,32.08311;118.985828,32.083137;118.995374,32.089017;118.997079,32.098872;118.992005,32.10218;119.004304,32.10818;119.007503,32.116052;119.01483,32.120846;119.017539,32.131831;119.026786,32.135426;119.041601,32.158965;119.057415,32.167054;119.082582,32.167576;119.083351,32.174839";
    final String jiangning_area = "118.623508,31.755646;118.630781,31.762592;118.642916,31.762436;118.648738,31.753937;118.64444,31.748077;118.652456,31.745091;118.654947,31.736528;118.674403,31.734758;118.687359,31.729113;118.690129,31.710369;118.683565,31.705178;118.672771,31.703127;118.675136,31.69629;118.669693,31.693951;118.668049,31.687888;118.648174,31.687368;118.647416,31.680802;118.65456,31.671292;118.646369,31.661278;118.65162,31.657684;118.651551,31.652841;118.693111,31.642265;118.718103,31.64835;118.726246,31.633249;118.731528,31.63314;118.731881,31.636771;118.739421,31.638465;118.748639,31.646803;118.74824,31.655575;118.753419,31.660604;118.750981,31.674031;118.754732,31.681427;118.76669,31.686086;118.774832,31.683473;118.780648,31.688708;118.804586,31.675025;118.79902,31.665729;118.789415,31.662253;118.799255,31.642047;118.796889,31.636404;118.802469,31.634668;118.811796,31.624728;118.823951,31.626924;118.827081,31.62943;118.826022,31.634718;118.839754,31.636537;118.846607,31.646454;118.857157,31.644582;118.854302,31.648492;118.856921,31.650484;118.869695,31.643334;118.872469,31.652409;118.891873,31.649024;118.894905,31.656376;118.891773,31.659304;118.896556,31.668226;118.910156,31.672145;118.914308,31.681017;118.91202,31.689257;118.916404,31.691699;118.932675,31.693929;118.943764,31.681;118.951374,31.680725;118.954307,31.685252;118.949554,31.689052;118.955502,31.705842;118.937391,31.726132;118.907678,31.741815;118.908514,31.753134;118.902421,31.770987;118.909946,31.783243;118.911971,31.793892;118.958893,31.773943;118.978079,31.774988;118.984577,31.771471;118.989539,31.78059;118.989405,31.788963;119.00948,31.789319;119.014411,31.798312;119.013153,31.804704;119.004522,31.808776;118.994918,31.823248;118.979629,31.82859;118.977906,31.84197;118.984465,31.841931;118.986302,31.848011;119.036431,31.854505;119.040106,31.860406;119.049807,31.860792;119.052301,31.86476;119.075475,31.875195;119.079904,31.870041;119.101047,31.865819;119.107064,31.87246;119.110669,31.88603;119.125289,31.894051;119.125815,31.903195;119.117899,31.907031;119.115053,31.92868;119.108022,31.938724;119.098071,31.937525;119.07489,31.94548;119.054033,31.942732;119.041638,31.948253;119.0358,31.95659;119.035715,31.963415;119.05309,31.975012;119.0714,31.979533;119.08154,31.975278;119.089448,31.980036;119.096742,31.979838;119.112303,31.970836;119.1175,31.974793;119.120509,31.98559;119.12748,31.986385;119.128206,31.990683;119.120919,31.993639;119.119066,32.006165;119.110651,32.010473;119.106451,32.007985;119.098962,32.009794;119.104511,32.016886;119.093202,32.05864;119.10516,32.077276;119.105493,32.09669;119.096383,32.095399;119.093003,32.097978;119.086351,32.113152;119.076235,32.114012;119.064137,32.108463;119.060157,32.110458;119.053517,32.107846;119.046892,32.114746;119.047366,32.119337;119.01483,32.120846;119.007503,32.116052;119.004304,32.10818;118.992005,32.10218;118.997079,32.098872;118.995374,32.089017;118.979802,32.082666;118.975873,32.086894;118.978691,32.098123;118.986538,32.103117;118.98749,32.115868;118.976253,32.117266;118.967054,32.108357;118.957781,32.106097;118.938534,32.085386;118.926626,32.082926;118.922091,32.05124;118.902239,32.03846;118.898223,32.033574;118.899475,32.028523;118.882552,32.017126;118.87331,32.005719;118.867872,32.007813;118.842895,31.98742;118.814464,31.982627;118.810382,31.972429;118.798345,31.977862;118.786364,31.967996;118.776198,31.965612;118.774477,31.951961;118.783571,31.929175;118.779675,31.926662;118.76712,31.922972;118.76161,31.924932;118.759333,31.921503;118.753321,31.921569;118.752395,31.92515;118.750448,31.921887;118.741978,31.925072;118.739313,31.922472;118.73372,31.925096;118.729969,31.937297;118.724745,31.939166;118.722246,31.934173;118.699202,31.931566;118.684523,31.924356;118.683146,31.920915;118.688377,31.914399;118.694485,31.913459;118.697271,31.907595;118.686321,31.903458;118.680267,31.908134;118.670512,31.907333;118.665442,31.903109;118.656424,31.906741;118.63772,31.928005;118.628146,31.932412;118.626496,31.930111;118.610657,31.939676;118.579968,31.922936;118.531099,31.876491;118.511281,31.847436;118.490243,31.787892;118.496669,31.781898;118.509807,31.783711;118.517358,31.77134;118.530153,31.767893;118.540352,31.773332;118.551938,31.768435;118.553799,31.765294;118.547957,31.764155;118.544955,31.756426;118.535924,31.754553;118.528698,31.748932;118.536553,31.748338;118.537649,31.742353;118.54279,31.744705;118.550584,31.73785;118.555126,31.743499;118.561209,31.734576;118.578155,31.752546;118.581766,31.747196;118.585837,31.746877;118.609267,31.760771;118.623508,31.755646";
    final String liuhe_area = "119.006535,32.510805;118.997435,32.509116;118.980851,32.512362;118.975595,32.533405;118.951424,32.549602;118.942924,32.564302;118.923048,32.562725;118.920942,32.55519;118.91284,32.558531;118.912592,32.564281;118.905799,32.559185;118.894449,32.560821;118.901024,32.567777;118.905152,32.566634;118.903639,32.582235;118.915644,32.592805;118.91427,32.598765;118.902497,32.592303;118.891642,32.592275;118.887812,32.584459;118.880008,32.588524;118.880368,32.582202;118.862592,32.580035;118.850105,32.57281;118.8512,32.580629;118.842699,32.576569;118.833568,32.578746;118.825776,32.590266;118.832033,32.601471;118.828785,32.61028;118.811757,32.599779;118.808675,32.590866;118.79123,32.588705;118.780687,32.593911;118.78203,32.604131;118.769479,32.609556;118.750952,32.604526;118.748889,32.596502;118.742117,32.59446;118.732625,32.602042;118.728696,32.618627;118.70413,32.612265;118.707333,32.594705;118.702996,32.594698;118.701117,32.603267;118.693661,32.611479;118.698287,32.599614;118.695985,32.594862;118.677834,32.601049;118.668497,32.599845;118.664353,32.605161;118.639981,32.583381;118.630451,32.598083;118.608383,32.603166;118.604648,32.607207;118.575571,32.5923;118.571351,32.568456;118.59121,32.555122;118.612451,32.546025;118.615494,32.542493;118.611104,32.52862;118.621077,32.526088;118.623429,32.521393;118.621952,32.514166;118.614603,32.507474;118.601638,32.508671;118.598991,32.506163;118.60113,32.486234;118.63472,32.473338;118.640887,32.477015;118.64999,32.476365;118.654229,32.482496;118.67897,32.475751;118.697382,32.478522;118.698104,32.459713;118.692466,32.434236;118.695103,32.406439;118.684705,32.398222;118.694444,32.391076;118.697995,32.383717;118.702381,32.389332;118.708187,32.386295;118.704741,32.381237;118.710051,32.375774;118.703131,32.372719;118.70698,32.364474;118.699891,32.360493;118.705715,32.355751;118.703331,32.349347;118.71455,32.342712;118.709624,32.335619;118.690488,32.333128;118.691495,32.329916;118.70373,32.325508;118.702387,32.323215;118.685304,32.322703;118.665752,32.309986;118.665134,32.304802;118.675321,32.301884;118.67757,32.292748;118.667641,32.270882;118.674152,32.264352;118.6825,32.261471;118.683669,32.256469;118.726454,32.254908;118.730878,32.221523;118.737648,32.215992;118.740328,32.203742;118.745706,32.197228;118.742709,32.194862;118.746162,32.186735;118.742455,32.180435;118.737139,32.17993;118.736441,32.172507;118.7406,32.172988;118.754547,32.189896;118.774637,32.194454;118.77279,32.211294;118.782841,32.220278;118.814771,32.23672;118.846341,32.234056;118.859598,32.226164;118.873143,32.205506;118.879483,32.187918;118.963099,32.18344;119.018011,32.188116;119.040469,32.197355;119.069616,32.228654;119.094119,32.246408;119.082998,32.253653;119.067036,32.249722;119.043509,32.266229;119.047491,32.27807;119.042787,32.300983;119.046449,32.30975;119.04205,32.315071;119.043613,32.333236;119.048398,32.33965;119.03488,32.351378;119.033753,32.357628;119.042474,32.362194;119.050678,32.372882;119.029504,32.383556;119.031781,32.386499;119.044828,32.387936;119.045429,32.391203;119.043582,32.395495;119.02963,32.397165;119.022968,32.411641;119.02452,32.42434;119.03072,32.427123;119.03595,32.435146;119.028549,32.447643;119.030203,32.456972;119.037218,32.461503;119.042358,32.458787;119.053185,32.469647;119.073963,32.468466;119.071053,32.488153;119.052249,32.504396;119.045519,32.522393;119.0362,32.52155;119.026271,32.524651;119.014063,32.520024;119.006535,32.510805";
    final String lishui_area = "119.083715,31.781847;119.083665,31.78983;119.072255,31.788041;119.062107,31.795229;119.05321,31.794888;119.041397,31.790012;119.034333,31.79052;119.021677,31.780942;119.012977,31.784761;119.005875,31.773163;118.99115,31.774968;118.984577,31.771471;118.978079,31.774988;118.958893,31.773943;118.911971,31.793892;118.909946,31.783243;118.902421,31.770987;118.908514,31.753134;118.907678,31.741815;118.937391,31.726132;118.947049,31.717312;118.955502,31.705842;118.949554,31.689052;118.954152,31.683658;118.951374,31.680725;118.943764,31.681;118.932675,31.693929;118.92312,31.694372;118.91377,31.690641;118.912798,31.676082;118.909339,31.671339;118.896807,31.668617;118.891773,31.659304;118.894905,31.656376;118.891873,31.649024;118.872469,31.652409;118.869695,31.643334;118.856921,31.650484;118.854302,31.648492;118.857157,31.644582;118.846607,31.646454;118.839754,31.636537;118.854817,31.629767;118.865176,31.629613;118.875337,31.617076;118.877397,31.60505;118.8687,31.598795;118.883916,31.595721;118.8782,31.579963;118.888543,31.570652;118.879466,31.551184;118.880613,31.538024;118.890463,31.537388;118.892802,31.533618;118.887175,31.493801;118.932432,31.443515;118.938861,31.426455;118.946329,31.418394;118.946497,31.411428;118.953498,31.404852;118.96313,31.401439;118.966723,31.393044;118.976532,31.386723;118.986062,31.390382;118.994287,31.399553;119.001399,31.401336;119.007887,31.389642;119.016652,31.392025;119.026558,31.407172;119.024228,31.420196;119.040812,31.435798;119.050121,31.435738;119.057516,31.429949;119.068967,31.438388;119.074777,31.431954;119.089522,31.438534;119.089094,31.431369;119.10691,31.429177;119.11088,31.424753;119.118971,31.42927;119.12221,31.426984;119.128274,31.428581;119.132843,31.443406;119.138154,31.447882;119.141186,31.443479;119.138234,31.424727;119.151577,31.425663;119.144452,31.447737;119.162336,31.481678;119.162304,31.486827;119.155074,31.493263;119.15946,31.499533;119.176322,31.500793;119.178205,31.50428;119.19004,31.506324;119.196036,31.51282;119.203802,31.527913;119.189396,31.53376;119.189134,31.546082;119.195206,31.557594;119.204647,31.557852;119.212171,31.562849;119.213076,31.56887;119.222426,31.57607;119.225005,31.584546;119.222637,31.591145;119.240656,31.632783;119.239104,31.637992;119.219036,31.633404;119.218389,31.639124;119.212805,31.642835;119.21132,31.6524;119.193616,31.655419;119.199334,31.665101;119.192572,31.677536;119.19695,31.693067;119.192954,31.700201;119.163847,31.705982;119.145188,31.728284;119.135825,31.729598;119.13156,31.741713;119.121033,31.74601;119.115491,31.752556;119.11742,31.757067;119.101312,31.761031;119.096253,31.775664;119.083715,31.781847";
    final String gaochun_area = "119.006566,31.238472;119.025694,31.247933;119.029362,31.244415;119.045898,31.244561;119.055297,31.239883;119.074125,31.243443;119.083023,31.238112;119.091107,31.245898;119.111856,31.240308;119.113641,31.256272;119.118583,31.262006;119.138711,31.268805;119.147122,31.282233;119.156523,31.283478;119.163939,31.298857;119.180472,31.299127;119.187398,31.306352;119.194872,31.307346;119.195368,31.313851;119.202346,31.31616;119.200243,31.324343;119.205731,31.33651;119.225634,31.35598;119.220769,31.361583;119.211092,31.363633;119.206907,31.374631;119.196289,31.385345;119.180574,31.387206;119.175616,31.400356;119.175655,31.427821;119.170845,31.447256;119.161978,31.444991;119.147396,31.451172;119.14502,31.44236;119.151738,31.428204;119.148516,31.423509;119.138234,31.424727;119.141186,31.443479;119.138154,31.447882;119.132843,31.443406;119.128274,31.428581;119.12221,31.426984;119.118971,31.42927;119.11088,31.424753;119.10691,31.429177;119.089094,31.431369;119.089522,31.438534;119.074777,31.431954;119.068967,31.438388;119.057516,31.429949;119.050121,31.435738;119.040812,31.435798;119.024228,31.420196;119.026558,31.407172;119.016652,31.392025;119.007887,31.389642;119.001399,31.401336;118.994287,31.399553;118.986062,31.390382;118.976532,31.386723;118.966723,31.393044;118.96313,31.401439;118.953498,31.404852;118.946497,31.411428;118.946329,31.418394;118.938861,31.426455;118.932432,31.443515;118.887175,31.493801;118.872749,31.450968;118.875957,31.428655;118.85813,31.401955;118.835518,31.383738;118.816456,31.376901;118.792159,31.37497;118.7785,31.370367;118.775892,31.371206;118.779132,31.380994;118.773141,31.393506;118.763709,31.391752;118.75138,31.37478;118.745573,31.357743;118.727757,31.331689;118.715597,31.30628;118.707724,31.303637;118.699751,31.305015;118.725885,31.285036;118.762892,31.276068;118.775131,31.264627;118.784072,31.246898;118.802201,31.2357;118.825927,31.24208;118.831427,31.235911;118.837802,31.235331;118.858179,31.245977;118.876885,31.248175;118.904315,31.244413;118.922137,31.250624;118.952889,31.241724;118.98811,31.244187;118.993096,31.236836;119.006566,31.238472";

    final int pukou_color = Color.parseColor("#B2FA83C1");

    final int qixia_color = Color.parseColor("#B2EFC4B4");

    final int jiangning_color = Color.parseColor("#B2FABF77");

    final int liuhe_color = Color.parseColor("#B2C479E1");

    final int lishui_color = Color.parseColor("#B2FAE577");

    final int gaochun_color = Color.parseColor("#B2D9D5AD");

    /**
     * 地图覆盖物的数据（常州）
     */

    final String tianning_area = "120.016838,31.756458;120.009445,31.760637;120.009497,31.768788;120.032474,31.770388;120.03942,31.778358;120.043314,31.797424;120.035328,31.808506;120.045659,31.817692;120.044919,31.821489;120.050794,31.827788;120.038899,31.831783;120.034517,31.837731;120.026219,31.830334;120.014454,31.834924;120.011913,31.832476;120.019679,31.824073;120.016696,31.81574;119.999445,31.81353;119.989374,31.806959;119.970998,31.814821;119.963008,31.80047;119.965375,31.79539;119.959151,31.774509;119.949358,31.771587;119.941211,31.763735;119.92822,31.761947;119.928927,31.756065;119.93864,31.756797;119.949915,31.753233;119.949928,31.750939;119.957852,31.752083;119.958096,31.747562;119.967808,31.748503;119.982404,31.742378;119.994594,31.742009;119.995008,31.734457;120.013721,31.737491;120.045997,31.727485;120.055993,31.728883;120.055015,31.725379;120.065088,31.720617;120.066478,31.729529;120.016838,31.756458";
    final String zhonglou_area = "119.881427,31.833923;119.881239,31.830308;119.874785,31.826052;119.868652,31.809089;119.872176,31.806844;119.871911,31.783282;119.867087,31.776695;119.869336,31.772333;119.876283,31.773629;119.876857,31.764983;119.88433,31.765493;119.891761,31.760304;119.892287,31.751865;119.902205,31.747512;119.917188,31.760446;119.92923,31.759623;119.928557,31.76294;119.941211,31.763735;119.949358,31.771587;119.958835,31.774196;119.965375,31.79539;119.963008,31.80047;119.970998,31.814821;119.957411,31.815231;119.954696,31.809537;119.934409,31.816749;119.926304,31.821733;119.931287,31.831398;119.91642,31.838458;119.915756,31.84869;119.900625,31.854204;119.898566,31.849809;119.895165,31.856196;119.881427,31.833923";
    final String qishuyan_area = "120.011748,31.759346;120.066478,31.729529;120.065088,31.720617;120.080953,31.715975;120.084468,31.717859;120.088305,31.727159;120.075449,31.732055;120.07619,31.742321;120.072982,31.744938;120.076738,31.753505;120.084306,31.756451;120.08249,31.766336;120.087537,31.773542;120.083805,31.784851;120.057531,31.782307;120.049289,31.785474;120.048001,31.779643;120.035886,31.777122;120.032474,31.770388;120.009829,31.769136;120.011748,31.759346";
    final String xinbei_area = "119.78588,32.004101;119.774108,31.955634;119.786802,31.947519;119.785087,31.944571;119.790945,31.943022;119.790473,31.936346;119.797471,31.934301;119.797047,31.930798;119.789154,31.92755;119.787959,31.911923;119.8015,31.901771;119.801708,31.888455;119.809578,31.890691;119.813857,31.883317;119.822658,31.886795;119.854266,31.879561;119.852662,31.872208;119.859959,31.870932;119.862406,31.864783;119.8578,31.843093;119.881239,31.830308;119.895165,31.856196;119.898566,31.849809;119.900625,31.854204;119.915756,31.84869;119.91642,31.838458;119.931287,31.831398;119.926304,31.821733;119.946729,31.811115;119.954696,31.809537;119.957411,31.815231;119.970998,31.814821;119.989374,31.806959;119.999445,31.81353;120.017006,31.815877;120.019679,31.824073;120.010309,31.833392;120.010143,31.844966;120.006269,31.844085;120.006236,31.850213;119.996921,31.859239;120.016889,31.871131;120.020875,31.888019;120.00425,31.900706;120.011671,31.917469;120.027214,31.925084;120.015024,31.939674;120.013567,31.952744;120.028889,31.973905;120.012035,31.986441;119.988198,32.013291;119.956143,32.008404;119.923224,32.011641;119.914192,32.020992;119.904167,32.043335;119.904184,32.051576;119.898607,32.053064;119.889225,32.046339;119.876089,32.06442;119.866448,32.057724;119.850567,32.065029;119.842111,32.059065;119.82389,32.061877;119.803067,32.056706;119.783912,32.020473;119.791544,32.017469;119.786335,32.01273;119.78588,32.004101";
    final String wujin_area = "120.092014,31.339252;120.106625,31.341528;120.102638,31.35862;120.063889,31.361788;120.048502,31.366826;120.04627,31.383961;120.051132,31.411983;120.061395,31.439949;120.067584,31.446072;120.090184,31.458496;120.116767,31.467573;120.11214,31.476774;120.115195,31.487304;120.134888,31.511804;120.126168,31.513868;120.127073,31.522513;120.115139,31.519373;120.109502,31.523825;120.108605,31.548418;120.104492,31.554364;120.090401,31.555356;120.08222,31.560425;120.074796,31.557624;120.064425,31.565965;120.067125,31.576225;120.063539,31.582011;120.081529,31.602378;120.081969,31.611696;120.108971,31.628121;120.11528,31.635553;120.121709,31.636876;120.126781,31.644313;120.130888,31.654597;120.134866,31.690625;120.149754,31.682212;120.155723,31.689678;120.152411,31.70332;120.160144,31.705094;120.163405,31.709718;120.161659,31.761157;120.172103,31.765669;120.185699,31.763021;120.19054,31.755569;120.208386,31.759131;120.191636,31.794289;120.18139,31.806638;120.184625,31.816371;120.174121,31.822778;120.169428,31.837033;120.170197,31.840608;120.176714,31.842471;120.194106,31.858587;120.193004,31.869075;120.183522,31.875375;120.168166,31.875677;120.161374,31.874112;120.150722,31.865045;120.129243,31.865712;120.122459,31.861113;120.101635,31.863567;120.058754,31.835504;120.044919,31.821489;120.046093,31.818356;120.041094,31.812346;120.035912,31.810331;120.036298,31.804844;120.043314,31.797424;120.03942,31.778358;120.048001,31.779643;120.04963,31.785551;120.057531,31.782307;120.083402,31.785054;120.083457,31.779591;120.086884,31.779889;120.084372,31.777489;120.087203,31.771515;120.08249,31.766336;120.083972,31.755492;120.076738,31.753505;120.073019,31.745447;120.07619,31.742321;120.075449,31.732055;120.088305,31.727159;120.080953,31.715975;120.055015,31.725379;120.055993,31.728883;120.045997,31.727485;120.013721,31.737491;119.995008,31.734457;119.994594,31.742009;119.982404,31.742378;119.967808,31.748503;119.958096,31.747562;119.957464,31.752254;119.949928,31.750939;119.949915,31.753233;119.93864,31.756797;119.929421,31.755933;119.92923,31.759623;119.923206,31.76142;119.915667,31.759623;119.902205,31.747512;119.892287,31.751865;119.891761,31.760304;119.88433,31.765493;119.876857,31.764983;119.876283,31.773629;119.869336,31.772333;119.867087,31.776695;119.871911,31.783282;119.872176,31.806844;119.868652,31.809089;119.87635,31.82883;119.881239,31.830308;119.8578,31.843093;119.862406,31.864783;119.859959,31.870932;119.852856,31.871892;119.855292,31.877976;119.84787,31.882802;119.822658,31.886795;119.81598,31.88288;119.809901,31.885797;119.809578,31.890691;119.801708,31.888455;119.8015,31.901771;119.787959,31.911923;119.787247,31.907875;119.778279,31.907134;119.76524,31.892122;119.759074,31.894705;119.758604,31.88783;119.770494,31.878945;119.76978,31.863252;119.776399,31.853935;119.788765,31.858217;119.817105,31.85763;119.804988,31.836563;119.796892,31.832574;119.797347,31.827527;119.792012,31.822847;119.797651,31.813241;119.770392,31.814503;119.765018,31.793304;119.755224,31.791722;119.752534,31.782654;119.745906,31.775702;119.74009,31.758915;119.741203,31.749811;119.747036,31.737418;119.757916,31.730963;119.752076,31.708922;119.738245,31.703084;119.708468,31.708747;119.700273,31.697006;119.706695,31.689256;119.704552,31.678871;119.712154,31.669226;119.706333,31.661021;119.696963,31.657747;119.696279,31.637344;119.681536,31.62822;119.678491,31.618315;119.681561,31.610143;119.691559,31.609784;119.706415,31.582203;119.716584,31.581705;119.719603,31.56291;119.722562,31.561509;119.738753,31.567938;119.770058,31.56037;119.798698,31.559345;119.814002,31.554231;119.834822,31.537943;119.847641,31.53437;119.854509,31.535929;119.868344,31.552474;119.915257,31.553917;119.939915,31.560353;119.954962,31.549056;119.978855,31.541814;119.984573,31.522365;119.992232,31.517856;119.998512,31.507611;120.003974,31.513013;120.011991,31.50966;120.022235,31.511694;120.042749,31.503774;120.052274,31.496656;120.050845,31.475464;120.044141,31.43176;120.034344,31.415098;120.02755,31.389179;120.030191,31.371082;120.048348,31.351691;120.092014,31.339252";
    final String liyang_area = "119.204106,31.27852;119.210846,31.271474;119.221887,31.279778;119.220528,31.274108;119.224762,31.270459;119.242871,31.265116;119.245661,31.260375;119.256503,31.262979;119.25657,31.267949;119.267871,31.267554;119.272031,31.257603;119.278868,31.257919;119.285777,31.264277;119.294639,31.264633;119.300931,31.269397;119.322326,31.271803;119.339847,31.269818;119.344176,31.264533;119.352558,31.274657;119.351693,31.280993;119.35679,31.286622;119.356735,31.306723;119.363197,31.309078;119.37438,31.295213;119.378082,31.277636;119.386175,31.275576;119.387178,31.267927;119.381166,31.264446;119.379938,31.254188;119.369956,31.244551;119.371761,31.238577;119.366662,31.217981;119.368837,31.208914;119.372319,31.201892;119.377742,31.203993;119.3812,31.195597;119.395127,31.201003;119.395695,31.198073;119.401341,31.205958;119.412079,31.200761;119.40177,31.199718;119.395738,31.194658;119.397907,31.180594;119.403719,31.180204;119.407028,31.18511;119.422185,31.17927;119.429662,31.187969;119.435035,31.187867;119.436969,31.183329;119.454233,31.176614;119.464009,31.163389;119.4824,31.164677;119.489041,31.158402;119.495618,31.170685;119.52034,31.162373;119.529905,31.16613;119.539029,31.16538;119.549125,31.181379;119.5601,31.185097;119.56083,31.197606;119.558503,31.23027;119.550665,31.232988;119.541433,31.241984;119.533894,31.24287;119.529048,31.248539;119.535225,31.254193;119.53355,31.258666;119.538679,31.2653;119.53691,31.27528;119.542118,31.27875;119.54197,31.282223;119.537163,31.284235;119.537825,31.294171;119.541628,31.297495;119.530291,31.307197;119.529347,31.317288;119.526079,31.319793;119.526852,31.325399;119.536982,31.337202;119.534626,31.371586;119.548195,31.400465;119.542685,31.414111;119.560368,31.42293;119.560138,31.439414;119.583801,31.436427;119.589049,31.442802;119.589954,31.451713;119.596216,31.453353;119.598373,31.468783;119.594766,31.472177;119.571752,31.470092;119.571029,31.476241;119.577472,31.478678;119.58115,31.486757;119.573012,31.498548;119.573612,31.510444;119.575488,31.512483;119.589776,31.509948;119.601591,31.539088;119.609013,31.546769;119.612681,31.557254;119.62211,31.564756;119.620264,31.57213;119.613953,31.576152;119.60461,31.575916;119.595804,31.567415;119.586776,31.570472;119.574335,31.568134;119.55829,31.574117;119.511341,31.581624;119.497375,31.577845;119.486564,31.580729;119.482236,31.585818;119.456276,31.582731;119.450035,31.593544;119.434932,31.595657;119.407232,31.63218;119.397015,31.634091;119.390638,31.640961;119.378766,31.632747;119.366898,31.636915;119.352203,31.649339;119.349062,31.659075;119.337038,31.672349;119.337522,31.679312;119.333987,31.682718;119.325338,31.683366;119.313257,31.666598;119.297061,31.65265;119.282391,31.647204;119.277421,31.640407;119.243531,31.630994;119.240656,31.632783;119.222637,31.591145;119.225005,31.584546;119.222426,31.57607;119.213076,31.56887;119.212171,31.562849;119.204647,31.557852;119.195206,31.557594;119.189134,31.546082;119.189396,31.53376;119.203972,31.526649;119.19004,31.506324;119.179149,31.504643;119.172845,31.499808;119.15946,31.499533;119.156879,31.496398;119.155349,31.49063;119.162304,31.486827;119.162336,31.481678;119.155461,31.464263;119.147031,31.45476;119.147396,31.451172;119.161978,31.444991;119.170845,31.447256;119.175655,31.427821;119.175616,31.400356;119.180574,31.387206;119.196289,31.385345;119.206907,31.374631;119.211092,31.363633;119.220769,31.361583;119.225634,31.35598;119.205731,31.33651;119.200243,31.324343;119.202346,31.31616;119.195368,31.313851;119.194872,31.307346;119.188061,31.306565;119.206019,31.299444;119.204106,31.27852";
    final String jintan_area = "119.381489,31.851311;119.37029,31.864037;119.352891,31.862557;119.34872,31.8652;119.338138,31.856857;119.336135,31.851472;119.340866,31.846884;119.339428,31.842337;119.331852,31.837558;119.320375,31.819782;119.323522,31.816129;119.320177,31.804403;119.325922,31.800617;119.324465,31.796421;119.328419,31.796253;119.311139,31.771687;119.312188,31.739132;119.328278,31.738386;119.338826,31.731976;119.328274,31.721635;119.331449,31.715901;119.327681,31.713452;119.335275,31.709715;119.33535,31.706914;119.325338,31.683366;119.336247,31.681471;119.337038,31.672349;119.349062,31.659075;119.352203,31.649339;119.366898,31.636915;119.378766,31.632747;119.384854,31.634598;119.38805,31.64118;119.397015,31.634091;119.407232,31.63218;119.434932,31.595657;119.450035,31.593544;119.456276,31.582731;119.482236,31.585818;119.486564,31.580729;119.497375,31.577845;119.511341,31.581624;119.55829,31.574117;119.574335,31.568134;119.586776,31.570472;119.595804,31.567415;119.60461,31.575916;119.613953,31.576152;119.621114,31.570965;119.62211,31.564756;119.63393,31.565804;119.653239,31.584033;119.649132,31.588729;119.645834,31.606631;119.664857,31.615691;119.67959,31.615279;119.681536,31.62822;119.696279,31.637344;119.696963,31.657747;119.706333,31.661021;119.712154,31.669226;119.704091,31.680195;119.7066,31.689508;119.700076,31.694865;119.706113,31.706207;119.713017,31.708837;119.737027,31.703155;119.746224,31.705391;119.754059,31.712132;119.757916,31.730963;119.750012,31.736777;119.714924,31.7436;119.713308,31.7528;119.701402,31.76111;119.694982,31.774944;119.662037,31.780262;119.651226,31.795105;119.651049,31.8019;119.638444,31.807234;119.63206,31.803024;119.61991,31.802869;119.612278,31.812044;119.611727,31.827977;119.605262,31.829347;119.603435,31.833304;119.597249,31.832977;119.599542,31.842029;119.595006,31.85025;119.583299,31.853873;119.576672,31.860251;119.566488,31.861907;119.563983,31.868539;119.556576,31.862448;119.514427,31.858022;119.490289,31.872318;119.474251,31.877676;119.470546,31.886873;119.455834,31.8912;119.444493,31.882377;119.430616,31.877608;119.433574,31.874648;119.424076,31.861999;119.42634,31.85786;119.432157,31.858575;119.449507,31.833196;119.439613,31.832949;119.434633,31.838753;119.428853,31.835548;119.410123,31.838592;119.393523,31.852942;119.381489,31.851311";

    final int zhonglou_color = Color.parseColor("#B2FA83C1");

    final int xinbei_color = Color.parseColor("#B2EFC4B4");

    final int wujin_color = Color.parseColor("#B2FABF77");

    final int tianning_color = Color.parseColor("#B2C479E1");

    final int qishuyan_color = Color.parseColor("#B2FAE577");

    final int liyang_color = Color.parseColor("#B2D9D5AD");

    final int jintan_color = Color.parseColor("#B27AAB77");


    private ConfigUtil configUtil = null;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        configUtil = new ConfigUtil(getResources());

        InitApplication initApplication = (InitApplication) getApplicationContext();

        initApplication.getActivities().add(this);

        //		mBMapMan = new BMapManager(getApplication());
        //
        //		mBMapMan.init(new InitApplication.MyGeneralListener());

        //		mBMapMan=new BMapManager();
        //		mBMapMan.init();

        setContentView(R.layout.jianguanduixiang_start);

        db = new DatabaseHelper(this, CommonConstants.DBNAME, null,
                CommonConstants.DATABASE_VERSION);

        wvStart = (WebView) findViewById(R.id.wvStart);

        btnLeft = (Button) findViewById(R.id.btnLeft);

        btnLast = (Button) findViewById(R.id.btnLast);

        btnLeft.setBackgroundColor(getResources().getColor(R.color.title_color));

        btnRight = (Button) findViewById(R.id.btnRight);

        btnLeft.setOnClickListener(this);

        btnRight.setOnClickListener(this);

        btnLast.setOnClickListener(this);

        btnBack = (ViewGroup) findViewById(R.id.btnBack);
        btnBack.setOnClickListener(this);

        blpLoading = (BlueLoadingProgress) findViewById(R.id.blpLoading);
        blpLoading.setVisibility(View.GONE);

        user = (User) getIntent().getSerializableExtra("user");

        // 存在网络的情况下

        // 启动javascr
        wvStart.getSettings().setJavaScriptEnabled(true);

        wvStart.getSettings().setLoadsImagesAutomatically(true);

        wvStart.setWebViewClient(new WebViewClient() {

            @Override
            public void onPageStarted(WebView view, String url, Bitmap favicon) {

                blpLoading.setVisibility(View.VISIBLE);

                super.onPageStarted(view, url, favicon);
            }

            @Override
            public void onPageFinished(WebView view, String url) {

                if (blpLoading != null) {
                    blpLoading.stopLoading();
                    blpLoading.setVisibility(View.GONE);
                }

                super.onPageFinished(view, url);
            }

//            @Override
//            public WebResourceResponse shouldInterceptRequest(WebView view, String url) {
//                url = url.toLowerCase();
//                if (!url.contains("http://jg.czfood360.cn/index.php")) {
//                    return new WebResourceResponse(null, null, null);
//                } else {
//                    return super.shouldInterceptRequest(view, url);
//                }
//            }
        });

        mvMap = (MapView) findViewById(R.id.mvMap);
        mBaiduMap = mvMap.getMap();


        mvMap.showZoomControls(true);

        //设置地图中心点,地图zoom级别
        LatLng cenpt = new LatLng(user.getRegion_latitude(), user.getRegion_longitude());
        ms = new MapStatus.Builder().target(cenpt).zoom(user.getRegion_zoom()).build();
        MapStatusUpdate mMapStatusUpdate = MapStatusUpdateFactory.newMapStatus(ms);
        mBaiduMap.setMapStatus(mMapStatusUpdate);

        if (configUtil.getRegionCode().equals("3201")) {
            drawArea(pukou_area, pukou_color);
            drawArea(qixia_area, qixia_color);
            drawArea(jiangning_area, jiangning_color);
            drawArea(liuhe_area, liuhe_color);
            drawArea(lishui_area, lishui_color);
            drawArea(gaochun_area, gaochun_color);
        } else {
            drawArea(tianning_area, tianning_color);
            drawArea(zhonglou_area, zhonglou_color);
            drawArea(qishuyan_area, qishuyan_color);
            drawArea(xinbei_area, xinbei_color);
            drawArea(wujin_area, wujin_color);
            drawArea(liyang_area, liyang_color);
            drawArea(jintan_area, jintan_color);
        }

        if (configUtil.gis()) {
            new AsyncTask<Integer, Integer, List<BeiJianDanWei>>() {

                private CustomDialog customDialog = null;

                @Override
                protected List<BeiJianDanWei> doInBackground(Integer... params) {

                    final List<BeiJianDanWei> beiJianDanWeis = new ArrayList<BeiJianDanWei>();

                    String requestUrl = new ConfigUtil(getResources())
                            .getPreHttpUrl()
                            + getString(R.string.jianguanduixiang_filter_url);
                    requestUrl += "/region_code/" + user.getKnowRegion();
                    String validateUsername = new ConfigUtil(getResources())
                            .getRestUsername();

                    String validatePassword = new ConfigUtil(getResources())
                            .getRestPassword();

                    HttpUtils httpUtils = HttpUtils.getInstance();

                    httpUtils.setOnRequestExecuted(new OnRequestExecuted() {

                        @Override
                        public void onRequestExecuted(int responseCode,
                                                      String responseBody) {
                            try {
                                JSONObject jsonObject = new JSONObject(
                                        responseBody);

                                String status = jsonObject.getString("status");

                                if ("1".equals(status) || "true".equals(status)) {

                                    JSONArray jsonArray = jsonObject
                                            .getJSONArray("result");

                                    for (int i = 0; i < jsonArray.length(); i++) {

                                        JSONObject jsonObjItem = jsonArray
                                                .getJSONObject(i);

                                        String id = jsonObjItem.getString("id");

                                        int isRed = 1;

                                        if (!jsonObjItem.isNull("color")) {
                                            isRed = jsonObjItem.getInt("color");
                                        }

                                        BeiJianDanWei beiJianDanWei = new BeiJianDanWei();
                                        beiJianDanWei.setId(id);
                                        beiJianDanWei.setLatitude(jsonObjItem.optDouble("latitude", 0));
                                        beiJianDanWei.setLongitude(jsonObjItem.optDouble("longitude", 0));

                                        if (beiJianDanWei != null) {

                                            beiJianDanWei.setIsRedData(isRed);

                                            beiJianDanWeis.add(beiJianDanWei);
                                        }

                                    }

                                }
                            } catch (JSONException e) {
                                responseCode = HttpUtils.UNKNOWERROR;
                            }

                        }

                    });

                    httpUtils.sendRequest(requestUrl, null, "GET", "UTF-8",
                            validateUsername, validatePassword, user);

                    return beiJianDanWeis;
                }

                @Override
                protected void onPostExecute(List<BeiJianDanWei> beiJianDanWeis) {
                    //                    customDialog.dismiss();

                    for (BeiJianDanWei beiJianDanWei : beiJianDanWeis) {

                        double mLat = beiJianDanWei.getLatitude();
                        double mLon = beiJianDanWei.getLongitude();


                        // 用给定的经纬度构造GeoPoint，单位是微度 (度 * 1E6)
                        GeoPoint p1 = new GeoPoint((int) (mLat * 1E6),
                                (int) (mLon * 1E6));

                        // 准备overlay图像数据，根据实情情况修复
                        // Drawable mark = getResources().getDrawable(
                        // R.drawable.icon_marka);
                        //
                        //						// 用OverlayItem准备Overlay数据
                        //						OverlayItem item = new OverlayItem(p1, "item1", "item1");
                        //
                        //						if (beiJianDanWei.getIsRedData() == 0) {
                        //							// 黄色
                        //							item.setMarker(JianGuanDuiXiangStatisticsActivity.this
                        //									.getResources().getDrawable(
                        //											R.drawable.ent_2));
                        //						} else {
                        //							// 红色
                        //							item.setMarker(JianGuanDuiXiangStatisticsActivity.this
                        //									.getResources().getDrawable(
                        //											R.drawable.ent_3));
                        //						}
                        //
                        //						// item2.setMarker(mark);
                        //
                        //						// 创建IteminizedOverlay
                        //						OverlayManager itemOverlay = new OverlayManager(
                        //								JianGuanDuiXiangStatisticsActivity.this
                        //										.getResources().getDrawable(
                        //										R.drawable.ent_2), mvMap);
                        //						// 将IteminizedOverlay添加到MapView中
                        //
                        //						itemOverlay.addItem(item);
                        //
                        //						mvMap.getOverlays().add(itemOverlay);

                        // 现在所有准备工作已准备好，使用以下方法管理overlay.
                        // 添加overlay,
                        // 当批量添加Overlay时使用addItem(List<OverlayItem>)效率更高
                        // itemOverlay.addItem(item1);
                        // itemOverlay.addItem(item2);
                        // itemOverlay.addItem(item3);
                        // mMapView.refresh();

                    }

                    //					mvMap.refresh();

                    super.onPostExecute(beiJianDanWeis);
                }

                @Override
                protected void onPreExecute() {
                    //                    customDialog = new CustomDialog(
                    //                            JianGuanDuiXiangStatisticsActivity.this);
                    //                    customDialog.setMessage("正在加载警示数据..");
                    //                    customDialog.showWait();
                    super.onPreExecute();
                }
            }.execute();

            //			mvMap.regMapStatusChangeListener(new MKMapStatusChangeListener() {
            //
            //				// private int userlatitude = (int) (user.getRegion_latitude() *
            //				// 1E6);
            //				//
            //				// private int userlongitude = (int) (user.getRegion_longitude()
            //				// *
            //				// 1E6);
            //
            //				private boolean showMessage = false;
            //
            //				@Override
            //				public void onMapStatusChange(MKMapStatus arg0) {
            //
            //					if (arg0.zoom < 10) {
            //
            //						if (!showMessage) {
            //
            //							Toast.makeText(
            //									JianGuanDuiXiangStatisticsActivity.this,
            //									"地图范围过大,请放大后查看..", Toast.LENGTH_LONG)
            //									.show();
            //
            //						}
            //
            //						showMessage = true;
            //
            //					} else {
            //
            //						showMessage = false;
            //
            //					}
            //				}
            //			});
        }

        loadRightTitle();

        if (!configUtil.gis()) {

            btnLeft.setVisibility(View.GONE);

            onClick(btnRight);

        } else {
            onClick(btnRight);
        }

    }

    /**
     * 加载去主页的按钮
     */
    public void loadRightTitle() {

        ViewGroup btnMeanMore = (ViewGroup) findViewById(R.id.btnMeanMore);

        View view = GoHomeUtil.createPopView(getApplicationContext(),
                new String[]{"主页"});

        // 弹出更多的菜单
        final PopupWindow pop = new PopupWindow(view,
                LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, false);

        // 需要设置一下此参数，点击外边可消失
        pop.setBackgroundDrawable(new BitmapDrawable());

        // 设置点击窗口外边窗口消失
        pop.setOutsideTouchable(true);

        // 设置此参数获得焦点，否则无法点击
        pop.setFocusable(true);

        final Button btn01 = (Button) pop.getContentView().findViewWithTag(
                "btn0");

        // final Button btn02 = (Button) pop.getContentView().findViewWithTag(
        // "btn1");
        //
        // final Button btn03 = (Button) pop.getContentView().findViewWithTag(
        // "btn2");

        OnClickListener menuOnClick = new OnClickListener() {

            @Override
            public void onClick(View v) {

                if (v == btn01) {
                    GoHomeUtil.goHome(getApplicationContext());
                }

                // if (v == btn02) {
                //
                // GregorianCalendar calendar = new GregorianCalendar();
                // calendar.add(Calendar.YEAR, -1);
                //
                // String year = calendar.get(Calendar.YEAR) + "";
                //
                // String url = new ConfigUtil(getResources()).getPreHttpUrl()
                // + getString(R.string.jianguanduixiang_count_url)
                // + user.getKnowRegion() + "/username/"
                // + user.getUsername() + "/from/1" + "/year/" + year;
                //
                //
                // wvStart.loadUrl(url);
                // titleState.setText("当前数据:去年");
                // }
                //
                // if (v == btn03) {
                //
                // String url = new ConfigUtil(getResources()).getPreHttpUrl()
                // + getString(R.string.jianguanduixiang_count_url)
                // + user.getKnowRegion() + "/username/"
                // + user.getUsername() + "/from/1" ;
                //
                // Log.d("url~~", url) ;
                //
                // wvStart.loadUrl(url);
                // titleState.setText("当前数据:今年");
                // }

                pop.dismiss();

            }
        };

        btn01.setOnClickListener(menuOnClick);

        // btn02.setOnClickListener(menuOnClick);
        //
        // btn03.setOnClickListener(menuOnClick);

        btnMeanMore = (ViewGroup) findViewById(R.id.btnMeanMore);

        btnMeanMore.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {

                if (pop.isShowing()) {
                    // 隐藏窗口，如果设置了点击窗口外小时即不需要此方式隐藏
                    pop.dismiss();
                } else {
                    // 显示窗口
                    pop.showAsDropDown(v);
                }

            }
        });

    }

    @Override
    protected void onDestroy() {

        InitApplication initApplication = (InitApplication) getApplicationContext();

        initApplication.getActivities().remove(this);

        //		mvMap.destroy();
        //		if (mBMapMan != null) {
        //			mBMapMan.destroy();
        //			mBMapMan = null;
        //		}

        if (db != null) {
            db.close();
        }

        super.onDestroy();
    }

    @Override
    protected void onPause() {
        mvMap.onPause();
        //		if (mBMapMan != null) {
        ////			mBMapMan.stop();
        //		}
        super.onPause();
    }

    @Override
    protected void onResume() {
        mvMap.onResume();
        //		if (mBMapMan != null) {
        ////			mBMapMan.start();
        //		}
        super.onResume();
    }

    @Override
    public void onClick(View v) {

        if (v == btnBack) {
            finish();
            return;
        }

        //        btnLeft.setBackgroundResource(R.drawable.btn_back_pressed);
        //        btnRight.setBackgroundResource(R.drawable.btn_back_pressed);
        //        btnLast.setBackgroundResource(R.drawable.btn_back_pressed);

        if (v == btnLeft) {

            //			MapController mMapController = mvMap.getController();
            //
            //			// 得到mMapView的控制权,可以用它控制和驱动平移和缩放
            //			GeoPoint point = new GeoPoint(
            //					(int) (user.getRegion_latitude() * 1E6),
            //					(int) (user.getRegion_longitude() * 1E6));
            //
            //			// 用给定的经纬度构造一个GeoPoint，单位是微度 (度 * 1E6)
            //			mMapController.setCenter(point);// 设置地图中心点
            //			mMapController.setZoom(user.getRegion_zoom());// 设置地图zoom级别

            mvMap.setVisibility(View.VISIBLE);

            wvStart.setVisibility(View.GONE);
            btnLeft.setBackgroundResource(R.drawable.btn_back_pressed);
            btnRight.setBackgroundResource(R.drawable.btn_back_pressed);
            btnLast.setBackgroundResource(R.drawable.btn_back_pressed);
            btnLeft.setBackgroundColor(getResources().getColor(
                    R.color.title_color));

        } else if (btnRight == v) {

            mvMap.setVisibility(View.GONE);

            wvStart.setVisibility(View.VISIBLE);

            String url = new ConfigUtil(getResources()).getPreHttpUrl()
                    + getString(R.string.jianguanduixiang_count_url)
                    + user.getKnowRegion() + "/username/" + user.getUsername()
                    + "/from/1";

            wvStart.loadUrl(url);
            btnLeft.setBackgroundResource(R.drawable.btn_back_pressed);
            btnRight.setBackgroundResource(R.drawable.btn_back_pressed);
            btnLast.setBackgroundResource(R.drawable.btn_back_pressed);
            btnRight.setBackgroundColor(getResources().getColor(
                    R.color.title_color));

        } else if (btnLast == v) {

            //            btnLast.setBackgroundColor(getResources().getColor(
            //                    R.color.title_color));

            Intent intent = new Intent(this, JianGuanDuiXiangActivity.class);

            // 传递到下一个页面
            intent.putExtra("user", this.user);

            startActivity(intent);

            //            btnLast.setBackgroundResource(R.drawable.btn_back_pressed);

            //            if (configUtil.gis()) {
            //
            //                onClick(btnLeft);
            //            } else {
            //                onClick(btnRight);
            //            }

        }

    }

    /**
     * 自定义标记
     */
    //	class OverlayManager extends ItemizedOverlay<OverlayItem> {
    //
    //		public OverlayManager(Drawable mark, MapView mapView) {
    //			super(mark, mapView);
    //		}
    //
    //		protected boolean onTap(int index) {
    //			// 在此处理item点击事件
    //			return true;
    //		}
    //
    //		public boolean onTap(GeoPoint pt, MapView mapView) {
    //			// 在此处理MapView的点击事件，当返回 true时
    //			super.onTap(pt, mapView);
    //			return false;
    //		}
    //
    //	}

    /**
     * 根据各区域点绘制
     *
     * @param area
     * @return
     */
    private void drawArea(String area, int color) {
        List<LatLng> pts = new ArrayList<>();

        String[] points = area.split(";");

        for (int i = 0; i < points.length; i++) {
            String[] point = points[i].split(",");
            LatLng pt = new LatLng(Double.parseDouble(point[1]), Double.parseDouble(point[0]));

            pts.add(pt);
        }

        OverlayOptions p0 = new PolygonOptions()
                .points(pts)
                .stroke(new Stroke(5, color))
                .fillColor(color);
        mBaiduMap.addOverlay(p0);
    }
}
